import {
    get_deploying_tasks,
    get_trash_tasks,
    get_task_detail,
    get_lined_tasks
} from '../actions/task';

function tasks (state = {
    deployingTasks: [],
    trashTasks: [],
    linedTasks: [],
    projectId: 0,
    taskId: 0,
    projectName: "",
    taskName: "",
    markContent: "",
    testHost: null,
    prevHost: null,
    admin: {},
    tester: {},
    developer: {},
    deployStatus: 0,
    serversList: []
}, action) {
    switch (action.type) {
        case get_task_detail:
            return Object.assign({}, state, {
                projectId: action.projectId,
                taskId: action.taskId,
                projectName: action.projectName,
                taskName: action.taskName,
                deployStatus: action.deployStatus,
                testHost: action.testHost,
                prevHost: action.prevHost,
                serversList: action.serversList,
                markContent: action.markContent,
                admin: action.admin,
                tester: action.tester,
                developer: action.developer
            });
        case get_deploying_tasks:
            return Object.assign({}, state, {
                deployingTasks: action.list
            });
        case get_trash_tasks:
            return Object.assign({}, state, {
                trashTasks: action.list
            });
        case get_lined_tasks:
            return Object.assign({}, state, {
                linedTasks: action.list
            });    
        default:
            return state;
    }
}

export default tasks;